﻿module OptionTest

open Xunit
open FsUnit.Xunit

let div x  y = 
    match y with
    | 0 -> None
    | _ -> Some(x/y);;

[<Fact>]
let ``Divide None``()=
    (div 10 0).IsNone |> should equal true

[<Fact>]
let ``Divide OK``()=
    (div 10 2).Value |> should equal 5

[<Fact>]
let ``Pattern Matching Option Types``()=
    let isFortyTwo = function
        |Some(42) -> true
        |Some(_) | None -> false

    isFortyTwo (Some(42)) |> should equal true
    isFortyTwo None |> should equal false
    isFortyTwo (Some(5)) |> should equal false



    

